//
//  FinishBindBoxVC.m
//  hnGovernment
//
//  Created by 安仔 on 17/3/6.
//  Copyright © 2017年 安仔. All rights reserved.
//

#import "FinishBindBoxVC.h"
#import "DDHudHelper.h"
#import "DDcacheManager.h"
#import "DDbaseNetWork+Login.h"
#import "PersonInformVC.h"

@interface FinishBindBoxVC ()
@property (nonatomic, strong) UIButton *finishBtn;
@property (nonatomic, strong) UILabel *contentLab;

@end

@implementation FinishBindBoxVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = NSLocalString(@"绑定邮箱");
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIImageView *signImg = [[UIImageView alloc] initWithFrame:CGRectMake(296 * m6Scale, 94 * m6Scale, 144 * m6Scale, 120 *m6Scale)];
    signImg.image = [UIImage imageNamed:@"邮箱绑定成功"];
    [self.view addSubview:signImg];
    
    
    self.contentLab = [[UILabel alloc] initWithFrame:CGRectMake(72 * m6Scale, 280 * m6Scale, 600 * m6Scale, 88 * m6Scale)];
    NSString *email = [[@"已发送验证链接至\n" stringByAppendingString:_emailStr] stringByAppendingString:@"请查收并验证邮箱"];
    self.contentLab.text = NSLocalString(email);
    self.contentLab.numberOfLines = 0;
    self.contentLab.font = [UIFont systemFontOfSize:32 * m6Scale];
    self.contentLab.textAlignment = NSTextAlignmentCenter;
    self.contentLab.textColor = RGB(103, 103, 103);
    
    //修改字体颜色
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:self.contentLab.text];
    [str addAttribute:NSForegroundColorAttributeName value:APPColor range:NSMakeRange(8,_emailStr.length+1)];
    self.contentLab.attributedText = str;
    [self.view addSubview:self.contentLab];
    
    
    self.finishBtn = [[UIButton alloc] initWithFrame:CGRectMake(72 * m6Scale, 434 * m6Scale, 600 * m6Scale, 80 * m6Scale)];
    [self.finishBtn setTitle:NSLocalString(@"确认") forState:0];
    [self.finishBtn setTitleColor:[UIColor whiteColor] forState:0];
    self.finishBtn.backgroundColor = APPColor;
    self.finishBtn.layer.cornerRadius = 10 * m6Scale;
    [self.finishBtn addTarget:self action:@selector(finishBind) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.finishBtn];
    
}

- (void) finishBind {
    
    ZWUserModel *model = [cacheManager getUserModel];
    model.email = self.emailStr;
    [cacheManager cacheUserInfoWithModel:model];
    
    for (UIViewController *vc in self.navigationController.viewControllers) {
        if ([vc isKindOfClass:[PersonInformVC class]]) {
            [self.navigationController popToViewController:vc animated:YES];
        }
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
